package com.jh.user.repository;

import com.jh.user.pojo.ThirdPayRate;
import com.jh.user.pojo.enums.ThirdPayType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Yichuan
 * @version 1.0
 */
@Repository
public interface ThirdPayRateRepository extends
        JpaRepository<ThirdPayRate, Long>,
        JpaSpecificationExecutor<ThirdPayRate> {

    /**
     * 查询指定贴牌的第三方支付费率信息
     *
     * @param brandId 贴牌id
     * @return 返回指定贴牌的第三方支付费率信息
     */
    List<ThirdPayRate> findByBrandId(Long brandId);


    /**
     * 查询指定支付费率信息
     *
     * @param brandId 贴牌id
     * @param type 类型
     * @return 返回支付费率信息
     */
    @Query("select tpr from ThirdPayRate tpr where tpr.brandId=:brandId and tpr.type=:type")
    ThirdPayRate findThirdPayRate(@Param("brandId") Long brandId, @Param("type")ThirdPayType type);
}
